package cn.itsource.org.mapper;

import cn.itsource.org.domain.User;
import cn.itsource.org.pojo.dto.LoginDto;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;

public interface UserMapper extends Mapper<User> {

    //基础的crud全部都是通过继承得到

    //通过手机号查询
    default User findByPhone(String phone){

        //查询条件
        Example example = new Example(User.class);
        example.and().andEqualTo("phone",phone);
        //查询
        return this.selectOneByExample(example);
    }

    @Select("select * from t_user where username = #{username} or phone = #{username} or email = #{username}")
    User findByUsername(LoginDto loginDto);
}
